home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 400_01 / socketpp-1.5 / sockunix.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-06  |  2.1 KB  |  96 lines

  1. // sockunix.C -*- C++ -*- socket library
  2. // Copyright (C) 1992,1993 Gnanasekaran Swaminathan <gs4t@virginia.edu>
  3. // 
  4. // Permission is granted to use at your own risk and distribute this software
  5. // in source and binary forms provided the above copyright
  6. // notice and this paragraph are preserved on all copies.
  7. // This software is provided "as is" with no express or implied warranty.
  8. //
  9. // Version: 31Jan93 1.3
  10.  
  11. #include <sockunix.h>
  12.  
  13. extern "C" {
  14.     int            socket (int domain, int type, int proto);
  15. }
  16.  
  17. sockunixaddr::sockunixaddr (const char* path)
  18. {
  19.     sun_family = sockunixbuf::af_unix;
  20.     ::strcpy (sun_path, path);
  21. }
  22.  
  23. sockunixbuf::sockunixbuf (sockbuf::type ty, int proto=0)
  24. : sockbuf (af_unix, ty, proto)
  25. {}
  26.  
  27. sockunixbuf& sockunixbuf::operator = (sockbuf& su)
  28. {
  29.     this->sockbuf::operator = (su);
  30.     return *this;
  31. }
  32.  
  33. sockbuf* sockunixbuf::open (type st, int proto)
  34. {
  35.     *this = sockunixbuf (st, proto);
  36.     return this;    
  37. }
  38.  
  39. void sockunixbuf::bind (sockAddr& sa)
  40. {
  41.     sockbuf::bind (sa);
  42. }
  43.  
  44. void sockunixbuf::bind (const char* path)
  45. {
  46.     sockunixaddr sa (path);
  47.     bind (sa);
  48. }
  49.  
  50. void sockunixbuf::connect (sockAddr& sa)
  51. {
  52.     sockbuf::connect (sa);
  53. }
  54.  
  55. void sockunixbuf::connect (const char* path)
  56. {
  57.     sockunixaddr sa (path);
  58.     connect (sa);
  59. }
  60.  
  61. isockunix::isockunix (sockbuf::type ty, int proto)
  62. : ios (new sockunixbuf (ty, proto))
  63. {
  64.     unsetf (ios::dont_close); // ios::~ios deletes rdbuf()
  65. }
  66.  
  67. isockunix::isockunix (const sockbuf& sb)
  68. : ios (new sockunixbuf (sb))
  69. {
  70.     unsetf (ios::dont_close); // ios::~ios deletes rdbuf()
  71. }
  72.  
  73. osockunix::osockunix (sockbuf::type ty, int proto)
  74. : ios (new sockunixbuf (ty, proto))
  75. {
  76.     unsetf (ios::dont_close); // ios::~ios deletes rdbuf()
  77. }
  78.  
  79. osockunix::osockunix (const sockbuf& sb)
  80. : ios (new sockunixbuf (sb))
  81. {
  82.     unsetf (ios::dont_close); // ios::~ios deletes rdbuf()
  83. }
  84.  
  85. iosockunix::iosockunix (sockbuf::type ty, int proto)
  86. : ios (new sockunixbuf (ty, proto))
  87. {
  88.     unsetf (ios::dont_close); // ios::~ios deletes rdbuf()
  89. }
  90.  
  91. iosockunix::iosockunix (const sockbuf& sb)
  92. : ios (new sockunixbuf (sb))
  93. {
  94.     unsetf (ios::dont_close); // ios::~ios deletes rdbuf()
  95. }
  96.